package org.devocean.groupbuying.domain;

import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.OneToMany;
import javax.persistence.Transient;

@SuppressWarnings("serial")
@Entity
public class Customer implements Serializable {

	@Id
	@GeneratedValue
	private Integer customerID;
	private String userName;
	private String firstName;
	private String lastName;
	private String password;
	private Boolean enabled;
	@Transient
	private String confirmPassword;
	@Transient
	private String actualPassword;
	private String uuid;
	private String phone;
	private String adress;
	private String country;
	private String state;
	private String city;
	private String zipCode;
	private String email;
	private Double credit;

	@OneToMany(cascade = CascadeType.ALL, mappedBy = "customer")
	private Set<Purchase> purchases = new HashSet<Purchase>();

	@ManyToMany(fetch = FetchType.EAGER)
	@JoinTable(name = "customerRole", joinColumns = { @JoinColumn(name = "customerID", referencedColumnName = "customerID") }, inverseJoinColumns = { @JoinColumn(name = "roleID", referencedColumnName = "roleID") })
	private Set<Role> customerRoles = new HashSet<Role>();

	public Integer getCustomerID() {
		return customerID;
	}

	public void setCustomerID(Integer customerID) {
		this.customerID = customerID;
	}

	public String getUserName() {
		return userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public Boolean getEnabled() {
		return enabled;
	}

	public void setEnabled(Boolean enabled) {
		this.enabled = enabled;
	}

	public String getConfirmPassword() {
		return confirmPassword;
	}

	public void setConfirmPassword(String confirmPassword) {
		this.confirmPassword = confirmPassword;
	}

	public String getActualPassword() {
		return actualPassword;
	}

	public void setActualPassword(String actualPassword) {
		this.actualPassword = actualPassword;
	}

	public String getUuid() {
		return uuid;
	}

	public void setUuid(String uuid) {
		this.uuid = uuid;
	}

	public String getPhone() {
		return phone;
	}

	public void setPhone(String phone) {
		this.phone = phone;
	}

	public String getAdress() {
		return adress;
	}

	public void setAdress(String adress) {
		this.adress = adress;
	}

	public String getCountry() {
		return country;
	}

	public void setCountry(String country) {
		this.country = country;
	}

	public String getState() {
		return state;
	}

	public void setState(String state) {
		this.state = state;
	}

	public String getCity() {
		return city;
	}

	public void setCity(String city) {
		this.city = city;
	}

	public String getZipCode() {
		return zipCode;
	}

	public void setZipCode(String zipCode) {
		this.zipCode = zipCode;
	}

	public Set<Purchase> getPurchases() {
		return purchases;
	}

	public void setPurchases(Set<Purchase> purchases) {
		this.purchases = purchases;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public Set<Role> getCustomerRoles() {
		return customerRoles;
	}

	public void setCustomerRoles(Set<Role> customerRoles) {
		this.customerRoles = customerRoles;
	}

	public String getFirstName() {
		return firstName;
	}

	public void setFirstName(String firstName) {
		this.firstName = firstName;
	}

	public String getLastName() {
		return lastName;
	}

	public void setLastName(String lastName) {
		this.lastName = lastName;
	}

	public Double getCredit() {
		return credit;
	}

	public void setCredit(Double credit) {
		this.credit = credit;
	}

	public String toString() {
		return "Customer [userName=" + userName + ", enabled=" + enabled
				+ ", uuid=" + uuid + ", phone=" + phone + ", adress=" + adress
				+ ", country=" + country + ", state=" + state + ", city="
				+ city + ", zipCode=" + zipCode + ", email=" + email + "]";
	}

}
